﻿<Button OnClick="AppendData" BackgroundColor=TablerColor.Primary>Append Data</Button>
<DemoContainer>
    <ApexChart @ref=chart TItem="Order"
               Title="Order Gross Value">

        <ApexPointSeries TItem="Order"
                    Items="Orders"
                    SeriesType="SeriesType.Donut"
                    Name="Gross Value"
                    XValue="@(e => e.Country)"
                    YAggregate="@(e => e.Sum(e => e.GrossValue))"
                    OrderByDescending="e=>e.Y" />
    </ApexChart>
</DemoContainer>

@code {
    private List<Order> Orders { get; set; } = SampleData.GetOrders();
    private ApexChart<Order> chart;

    private async Task AppendData()
    {
        var newOrders = SampleData.GetRandomOrders();
        Orders.AddRange(newOrders);
        await chart.AppendDataAsync(newOrders);
    }

    }